home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wildcard.zip / FIND.ASM < prev    next >
Assembly Source File  |  1993-01-04  |  2KB  |  60 lines

  1.         NAME    FIND
  2.  
  3. PGROUP        GROUP    PROG
  4.  
  5. PROG        SEGMENT BYTE PUBLIC 'PROG'
  6.         ASSUME    CS:PGROUP
  7.         PUBLIC    FIND1ST, FINDNEXT
  8.  
  9. FIND1ST     PROC    NEAR
  10. ;
  11. ;    This procedure finds the first file that matches the name and set of
  12. ;    attributes passed in. If the file is found, a pointer to the information
  13. ;    block is returned, otherwise, zero is returned.
  14. ;
  15. WILDCARD    EQU    WORD PTR [BP + 4]
  16. ATTR_MASK    EQU    WORD PTR [BP + 6]
  17. DTA_P        EQU    WORD PTR [BP + 8]
  18.  
  19.         push    bp
  20.         mov    bp, sp
  21.         mov    dx, DTA_P            ; point to info block
  22.         mov    ah, 1Ah             ; request new DTA
  23.         int    21h                ; from MSDOS
  24.         mov    dx, WILDCARD            ; filename to find
  25.         mov    cx, ATTR_MASK            ; with these attributes
  26.         mov    ah, 4Eh             ; request search
  27.         int    21h                ; of DOS
  28.         mov    ax, 0                ; assume 0 (failure)
  29.         jc    DONE                ; if CY, no match
  30.         inc    ax                ; else success
  31. DONE:        pop    bp
  32.         ret
  33. FIND1ST     ENDP
  34.  
  35. FINDNEXT    PROC    NEAR
  36. ;
  37. ;    This procedure finds the next file that matches the name and set of
  38. ;    attributes passed in to FIND1ST.  This routine uses the information block
  39. ;    pointer that was passed to FIND1ST, and no changes to the block may
  40. ;    have taken place.    FINDNEXT false (0) when there are no more matches.
  41. ;
  42. INFO_BLOCK    EQU    WORD PTR [BP + 4]
  43.  
  44.         push    bp
  45.         mov    bp, sp
  46.         mov    dx, INFO_BLOCK            ; point to info block
  47.         mov    ah, 1Ah             ; request new DTA
  48.         int    21h                ; from MSDOS
  49.         mov    ah, 4Fh             ; request search
  50.         int    21h                ; of DOS
  51.         mov    ax, 0                ; assume 0 (failure)
  52.         jc    QUIT                ; if CY, no match
  53.         inc    ax                ; else TRUE (success)
  54. QUIT:        pop    bp
  55.         ret
  56. FINDNEXT    ENDP
  57.  
  58. PROG        ENDS
  59.         END
  60.